home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10639 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  46 lines

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: mvaccaro1@aol.com (MVaccaro1)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Getting output from system(cmd)
  5. Date: 18 Mar 1996 21:29:08 -0500
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4il65k$bol@newsbf02.news.aol.com>
  9. References: <4ijccg$r3s@castor.usc.edu>
  10. Reply-To: mvaccaro1@aol.com (MVaccaro1)
  11. NNTP-Posting-Host: newsbf02.mail.aol.com
  12.  
  13. James,
  14.  
  15. If your running in DOS you might want to redirecting the command output to
  16. a file.  Then latter in your program, you can open that file and reading
  17. it in.
  18.  
  19. I tried the following:
  20.  
  21. /*
  22. ** Test of redirection in system command
  23. */
  24.  
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27. #include <process.h>
  28.  
  29. int main( void )
  30.    {
  31.    int fStatus;
  32.    
  33.    fStatus = system( "mem > memory.dat" );
  34.    if ( fStatus == -1 )
  35.       printf( "\nFunction failed" );
  36.    return 0;
  37.    }
  38.   
  39. This runs the mem command and puts the output to disk in a file called
  40. MEMORY.DAT.  I hope this helps you.
  41.  
  42. Mike :->
  43.  
  44.  
  45. Design? What design! - I've too much coding to do...
  46.